import { NextResponse } from 'next/server';
import { prisma } from '@/lib/prisma';

export async function GET(
  request: Request,
  { params }: { params: { id: string } }
) {
  try {
    const trip = await prisma.trip.findUnique({
      where: { id: params.id },
      include: {
        activities: {
          orderBy: { date: 'asc' }
        }
      }
    });

    if (!trip) {
      return NextResponse.json({ error: '行程不存在' }, { status: 404 });
    }

    return NextResponse.json(trip);
  } catch (error) {
    console.error('Get trip data error:', error);
    return NextResponse.json(
      { error: '获取行程数据失败' },
      { status: 500 }
    );
  }
} 